Package("com.green.web.FunPermissionOAdd");
/* 费用类型 */
com.green.web.FunPermissionOAdd = {	
	init : function() {
		$list_dataGrid = $("#tableContainer").ligerGrid(
				$.extend($list_defaultGridParam, {
					columns : [ {display : 'ID',name : 'IDS',align : 'center',width : 1,hide:true
					},{display : 'FID',name : 'FID',align : 'center',width : 180,hide:true
					}, {display : '级别',name : 'MLEVEL',align : 'center',width : 180
					}, {display : '模块',name : 'MNAME',align : 'left',width : 180
					}, {display : '所属上级',name : 'MNAMES',align : 'left',width : 180
					}, {display : '操作',name : '',align : 'center',render:function (cv, rd, op) {
						if(null==cv.FID||cv.FID==""){
							op="<a href=\"javascript:com.green.web.FunPermissionOAdd.deleteFunPermission('1','"+cv.IDS+"');\">允许</a>";
						}else{
							op="<a href=\"javascript:com.green.web.FunPermissionOAdd.deleteFunPermission('2','"+cv.IDS+"');\">禁止</a>";
						}						
						 if(cv.MLEVEL=="2"){
							op=op+" | <a href=\"javascript:com.green.web.FunPermissionOAdd.getResource('"+cv.IDS+"');\">编辑权限</a>";		
					      }
						return op;
					}			
					} ],		 
					rownumbers : false,
					enabledSort : false,
					parms : {
						controUnit :$("#controUnit").val(),
						positionId :$("#positionId").val()
					},
					url : ctx + '/funPermission/listData'
				}));		
	},
	queryData : function(orgId) {	
		$list_dataParam['positionId'] = $("#positionId").val();
		$list_dataParam['controUnit'] = $("#controUnit").val(),
		resetList();
	},getResource:function(id){
		$("#moduleId").val(id);
		$.ajax({
			type : "POST",
			url : ctx + "/funPermission/getFunPermission",
			data : {
				"moduleId" : id,
				"positionId" : $("#positionId").val()
			},
			success : function(data) {
				art.dialog.data("returnFunName","selectResource");
				art.dialog.data("dataName",data.dataName);
				art.dialog.open(ctx+'/f7/index/getResource?fkmoduleid='+id,{title: '功能', lock: true,  skin: 'aero',padding:0,width:450,height:500});
			}
		});
		
	},
	deleteFunPermission : function(type,id) {
		art.dialog.confirm("确认操作次功能？", function() {
			$.ajax({
				type : "POST",
				url : ctx + "/funPermission/deleteFunPermission",
				data : {
					"id" : id,
					"type" : type,
					"positionId" : encodeURIComponent($("#positionId").val())
				},
				success : function(data) {
					var ss = $.trim(data.message);
					if (ss == 1 || ss=="1") {
						art.dialog.optTips('您的操作已经成功',2,"success");
						com.green.web.FunPermissionOAdd.queryData();
						art.dialog.close();
					} else {
						art.dialog.optTips('操作失败，请稍后再试',2,"failure");
					}
				}
			});
		});
	}
}